/*
 * File.hpp
 *
 *  Created on: 12 jun. 2013
 *      Author: maarten
 */

#ifndef FILE_HPP_
#define FILE_HPP_

#include <string>
#include "CommandCodes.hpp"

class File {
public:
	File(std::string aPath);
	virtual ~File();

	//open / close
	bool openFile();
	bool closeFile();
	bool isOpen();

	//checks
	std::string getPath();
	bool checkUploading();
	bool checkFileRead();
	bool checkFileWrite();
	bool checkExists();
	bool checkExtention();

	//control
	bool fileRename(std::string newPath);
	bool fileRemove();

	//file need to be opened:

	//upload mode
	bool setNextBlock(char * aBuffer, int length);

	//dowload mode
	char * getNextBlock();
	int getLastBlockSize();

private:
	int filedes;
	bool fileIsOpen;
	char buffer[FILESPLIT];
	int lastBlockSize;
	std::string path;
};

#endif /* FILE_HPP_ */
